package main


import (
    "fmt"
)


func change1 (a * int, b * int) {
    var temp int 
    temp = *a
    *a = *b
    *b = temp
}


func change2 (x int, y int) {
    var temp int 
    temp = x 
    x = y
    y = temp
}


var c, d int = 1, 2

func main(){
    var a, b int 
    a = 1
    b = 2
    fmt.Printf("局部变量的传址\n")
    fmt.Printf("原始数据%d %d \n", a, b)
    change1(&a, &b)
    fmt.Printf("change1:%d %d \n", a, b)
    
    fmt.Printf("局部变量的传值\n")
    fmt.Printf("原始数据%d %d \n", a, b)
    change2(a, b)
    fmt.Printf("change2:%d %d \n", a, b)
    
    fmt.Printf("全局变量原始数据c: %d d: %d \n", c, d)
    change1(&c, &d)
    fmt.Printf("change1:c: %d d: %d \n", c, d)

    fmt.Printf("全局变量原始数据c: %d d: %d \n", c, d)
    change2(c, d)
    fmt.Printf("change2:c: %d d: %d \n", c, d)




}

